<template>
	<view class="page-content">
		<u-navbar title=" " :background="background" :border-bottom="false" :is-back="false">

		</u-navbar>
		<image class="bg-user" src="../../static/image/bg-user.png" mode="widthFix"></image>
		<view style="position: relative;z-index: 10;">

			<view class="p12 u-f-item u-f-jsb" v-if="isLogin" @click="toPage('/pages/user/setting/info')">
				<view class="u-f-item" style="align-items: flex-start;">
					<view style="width: 150rpx;justify-content: center;position: relative;" class="u-flex">
						
							<u-avatar size="120" :src="userInfo.avatar"></u-avatar>
							<view class="role-show">{{memberRole}}</view>
					</view>
					<view class="pl8">
						
						<view class="fz16 mb8 c255" v-if="userInfo.company">{{userInfo.company}}</view>
						<view class="fz12 mb5 c255">{{userInfo.name}}</view>
						<view class="fz12 c255">{{userInfo.mobile}}</view>
						

						
					</view>
				</view>
				<view class="u-flex">
					<u-icon class="fz16" name="arrow-right" color="#fff"></u-icon>
				</view>
			</view>
			<view class="p12 u-f-item u-f-jsb" v-else @click="toLogin">
				<view class="u-f-item">
					<u-avatar size="116"></u-avatar>
					<view class="u-p-l-20">
						<view class="fz16 c255">登录注册</view>
					</view>
				</view>
				<u-icon name="arrow-right" color="#fff"></u-icon>
			</view>




			<view class="p12 pt16">
				
				<view class="p10 pt22 pb22 bg-white" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);" @click="toPage('/pages/rent/my')">
					
					<view class="fz12 c6 pb20" style="text-align: center;border-bottom:1px solid #F8F8F8">
						总资产(元)<view class="fz20 c3 mt8">{{(dataInfo.investmentAmount+dataInfo.unInvestmentAmount) || 0}}</view>
					</view>
					
					<view class="u-flex u-f-jsb mt20">
						<view class="fz12 c6 u-f1" style="text-align: center;">
							已投资(套)<view class="fz16 c3 mt8">{{dataInfo.investmentCount || 0}}</view>
						</view>
						<view class="fz12 c6 u-f1" style="text-align: center;">
							待审核(套)<view class="fz16 c3 mt8">{{dataInfo.unInvestmentCount || 0}}</view>
						</view>
						<view @click.stop="" class="fz12 c6 u-f1" style="text-align: center;">
							累计收益(元)<view class="fz16 c3 mt8">{{dataInfo.incomeAmount || 0}}</view>
						</view>
					</view>
					<view class="u-flex u-f-jsb mt20">
						<view class="fz12 c6 u-f1" style="text-align: center;">
							投资金额(元)<view class="fz16 c3 mt8">{{dataInfo.investmentAmount || 0}}</view>
						</view>
						<view class="fz12 c6 u-f1" style="text-align: center;">
							投资金额（待审）<view class="fz16 c3 mt8">{{dataInfo.unInvestmentAmount || 0}}</view>
						</view>
						<view class="fz12 c6 u-f1" style="text-align: center;">
							预计每月收入(元)<view class="fz16 c3 mt8">{{dataInfo.preMonthAmount || 0}}</view>
						</view>
					</view>
				</view>
				<view class="mt16 p16 bg-white" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);" @click="toPage('/pages/user/balance/index')">
					
					<view class="u-flex u-f-jsb fz16">
						我的钱包<span class="u-flex u-f-justify fz12 c6">
							查看详情<u-icon class="fz12" name="arrow-right" color="#666"></u-icon>
						</span>
					</view>
					
					
					<view class="u-flex u-f-jsb mt20">
						<view class="fz12 c6 u-f1" style="text-align: center;">
							累计收入(元)<view class="fz16 c3 mt8">{{moneyInfo.totalRecharge || 0}}</view>
						</view>
						<view class="fz12 c6 u-f1" style="text-align: center;">
							可用余额(元)<view class="fz16 c3 mt8">{{moneyInfo.balance || 0}}</view>
						</view>
						<view class="fz12 c6 u-f1" style="text-align: center;">
							提现中金额(元)<view class="fz16 c3 mt8">{{moneyInfo.applyAmount || 0}}</view>
						</view>
					</view>
					
				</view>
				
				<view class="mt16 p16 bg-white" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);">
					
					<view class="u-flex u-f-jsb fz16" @click="toPage('/pages/user/balance/index')">
						我的业务
					</view>
					
					
					<view class="u-flex u-f-jsb mt15">
						<view style="justify-content: center;" @click="toPage('/pages/house/my')" class="u-f1 bg-white mr6 u-flex"
							>
							<image src="../../static/image/ic-fy.png" style="width: 76rpx;height: 76rpx;"></image>
							<view class="pl12">
								<view class="fz14 c3">我的线索</view>
								<view class="fz12 c9 mt2">查看线索</view>
							</view>
						</view>
						<view @click="toPage('/pages/rent/my')" style="border-left: 1px solid #F8F8F8;justify-content: center;" class="u-f1 bg-white u-flex"
							>
							<image src="../../static/image/ic-qd.png" style="width: 76rpx;height: 76rpx;"></image>
							<view class="pl12">
								<view class="fz14 c3">我的投资</view>
								<view class="fz12 c9 mt2">查看房源</view>
							</view>
						</view>
					</view>
					
				</view>
				<view class="mt16 p16 bg-white" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);">
					
					<view class="u-flex u-f-jsb fz16" @click="toPage('/pages/user/balance/list')">
						我的收入<span class="u-flex u-f-justify fz12 c6">
							查看详情<u-icon class="fz12" name="arrow-right" color="#666"></u-icon>
						</span>
					</view>
					
					
					<view class="u-flex u-f-jsb mt20">
						<view class="fz12 c6 u-f1 item-count" @click="toPage('/pages/user/balance/list?type=0')" style="text-align: center;">
							<image src="../../static/image/sr1.png" class="w24 h24"></image>
							<view class="show-count">{{xsTotal.count}}</view>
							<view class="fz14 c3 mt4">线索奖励</view>
						</view>
						<view class="fz12 c6 u-f1 item-count" @click="toPage('/pages/user/balance/list?type=1')" style="text-align: center;">
							<view class="show-count">{{yjTotal.count}}</view>
							<image src="../../static/image/sr2.png" class="w24 h24"></image>
							<view class="fz14 c3 mt4">佣金奖励</view>
						</view>
						<view class="fz12 c6 u-f1 item-count" style="text-align: center;" @click="toPage('/pages/user/balance/list?type=2')">
							<view class="show-count">{{zjTotal.count}}</view>
							<image src="../../static/image/sr3.png" class="w24 h24"></image>
							<view class="fz14 c3 mt4">租金收益</view>
						</view>
						<view class="fz12 c6 u-f1 item-count" style="text-align: center;" @click="toPage('/pages/user/balance/list?type=3')">
							<view class="show-count">{{ywTotal.count}}</view>
							<image src="../../static/image/sr4.png" class="w24 h24"></image>
							<view class="fz14 c3 mt4">业务提成</view>
						</view>
					</view>
					
				</view>
				<view class="mt16 p16 bg-white" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);">
					
					<view class="u-flex u-f-jsb fz16" @click="toPage('/pages/invite/add')">
						我的团队<span class="u-flex u-f-justify fz12 c6">
							邀请码：{{userInfo.recommendOneselfCode}}<u-icon class="fz12" name="arrow-right" color="#666"></u-icon>
						</span>
					</view>
					
					
					<view class="u-flex u-f-jsb mt20" @click="toPage('/pages/invite/index')">
						<view class="fz16 c3  u-f1" style="text-align: center;">
							{{inviteInfo.rzUserCount || 0}}<view class="fz12 c6 mt6">已认证人数</view>
						</view>
						<view class="fz16 c3 u-f1" style="text-align: center;">
							{{(inviteInfo.client-inviteInfo.rzUserCount) || 0}}<view class="fz12 c6 mt6">待认证人数</view>
						</view>
					</view>
					
				</view>
				<view class="bg-white pt12 pb12 mt16" style="box-shadow: 0px 12px 40px -8px rgba(228,213,213,0.25);">
					<view class="u-flex u-f-jsb p12 pl14 pr14" style="position: relative;" v-for="(item, index) in actionList" :key="index"
						@click="toPage1(item)">
						<view class="u-flex">

							<image :src="item.img" mode="heightFix" style="height:48rpx;"></image>
							<view class="fz14 c3 ml8">{{ item.title }}</view>
						</view>
						<u-icon name="arrow-right" color="#333"></u-icon>
						<button class="kefu-btn" open-type="contact" v-if="item.path=='kefu'">
							联系客服
						</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		apiBaseUrl
	} from '../../config/config.js';
	import {
		getPlatform
	} from '@/config/util.js'
	export default {
		data() {
			return {
				isLogin: false,
				apiBaseUrl,
				background: {
					background: ''
				},
				memberRole:'',
				vipBg: '',
				moneyInfo:{},
				inviteInfo:{},
				xsTotal:{},
				yjTotal:{},
				ywTotal:{},
				zjTotal:{},
				showType: false,
				userInfo: {},
				dataInfo:{},
				actionList: [{
					title: '常见问题',
					path: '/pages/user/article/index?id=4',
					img: '../../static/image/u1.png'

				}, {
					title: '联系客服',
					path: '/pages/single/single?id=67',
					img: '../../static/image/u2.png'

				}, {
					title: '用户协议',
					path: '/pages/user/article/index?id=19',
					img: '../../static/image/u3.png'

				}, {
					title: '关于我们',
					path: '/pages/user/article/index?id=20',
					img: '../../static/image/u4.png'

				},  {
					title: '设置',
					path: '/pages/user/setting/index',
					img: '../../static/image/u5.png'

				},],
			}
		},
		onLoad() {},
		onShow() {
			if (this.$db.get("userToken")) {
				
				
				this.$api.memberInfo({}, res => {
					if (res.code == 200) {
						this.isLogin = true
						this.userInfo = res.data;
						
						
						this.$api.xsTotal({}, (res) => {
							if (res.code == 200) {
								this.xsTotal = res.data
							}
						})
						this.$api.yjTotal({}, (res) => {
							if (res.code == 200) {
								this.yjTotal = res.data
							}
						})
						this.$api.ywTotal({}, (res) => {
							if (res.code == 200) {
								this.ywTotal = res.data
							}
						})
						this.$api.zjTotal({}, (res) => {
							if (res.code == 200) {
								this.zjTotal = res.data
							}
						})
						this.$api.getChannelHead({}, res => {
							if (res.code == 200) {
								this.inviteInfo = res.data;
							}
						})
						this.$api.getNumber({}, res => {
							if (res.code == 200) {
								if (res.data) {
						
									this.dataInfo = res.data;
								}
							}
						})
						
						this.$api.getMeWallet({}, res => {
							if (res.code == 200) {
								if (res.data) {
						
									this.moneyInfo = res.data;
								}
							}
						})
						
						
							this.$api.dictList({
								dictType: 'changen_member_role'
							}, res => {
								if (res.code == 200) {
									res.data.some(item=>{
										if(item.value==this.userInfo.memberRole){
											this.memberRole=item.label
										}
									})
								}
							})
						
						
					}
				})

			}
		},
		methods: {

			
			toLogin() {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			},
			toPage1(item){
				if(item.title=='常见问题' || item.title=='用户协议' || item.title=='关于我们'){
					
					uni.navigateTo({
						url:item.path
					})
					return
				}
				this.toPage(item.path)
			},
			toPage(url) {
				if (!this.isLogin) {

					this.$common.errorToShow('请先登录！')
					uni.navigateTo({
						url: '/pages/login/index'
					})
				} else {
					uni.navigateTo({
						url
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.btn {
		width: 144rpx;
		height: 50rpx;
		text-align: center;
		color: #fff;
		line-height: 50rpx;
		background: #ABC7C9;
		border-radius: 40px;
	}

	.bg-shaw {
		box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.08);
	}


	.kefu-btn {
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 1;
		opacity: 0;
	}

	.module-vip {
		position: relative;

		.bg-vip {
			display: block;
			width: 100%;
			height: 140rpx;
		}

		.bg-vip-bottom {

			position: absolute;
			bottom: 0;
			z-index: 1;
			left: 0;
			right: 0;
			height: 48rpx;
			width: 100%;
		}

		.vip-info {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			color: #fff;
			padding: 24rpx 36rpx;
		}

		.btn-vip {
			background: linear-gradient(135deg, #FEFEFE 0%, #C1F3FA 50%, #A5DAFA 100%);
			border-radius: 16rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 24rpx;
			color: #19291C;
			padding: 10rpx 24rpx;
		}
	}

	.btn-edit {
		background: #E57718;
		border-radius: 27rpx;
		font-family: Source Han Sans CN;
		font-size: 26rpx;
		color: #fff;
		padding: 8rpx 30rpx;

	}

	.line {
		width: 702px;
		height: 4px;
		background: #F6F9F9;
		border-radius: 0px 0px 0px 0px;
	}
	.bg-user{
		position: absolute;
		z-index: 1;
		top: 0;
		width: 100%;
		
	}
	.act-img{
		width: 116rpx;height: 80rpx;display: block;margin: 0 auto;
	}
	.role-show{
		background: rgba(255, 255, 255, 0.8);
		position: absolute;
		left: 0;
		right: 0;
		bottom: -30rpx;
		border-radius: 50rpx;
		text-align: center;
		color: #F24646;
		padding: 6rpx;
	}
	.item-count{
		position: relative;
		.show-count{
			font-size: 12px;
			position: absolute;
			top: 0;
			left: 50%;
			color: #F24646;
			margin-left: 26rpx;
		}
	}
</style>